package com.yzkj.siot.controller;

import com.yzkj.siot.annotation.Permission;
import com.yzkj.siot.annotation.WebLog;
import com.yzkj.siot.base.BaseController;
import com.yzkj.siot.domain.TenantUser;
import com.yzkj.siot.facade.UserFacade;
import com.yzkj.siot.result.PageParams;
import com.yzkj.siot.result.PageResponse;
import com.yzkj.siot.type.ApiType;
import com.yzkj.siot.type.PermissionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController extends BaseController {

    @Autowired
    UserFacade facade;

    @WebLog(type = ApiType.READ)
    @Permission(type = PermissionType.TENANT)
    @PostMapping("page")
    public PageResponse<TenantUser> page(@RequestBody PageParams<TenantUser> pageParams) {
        return this.facade.page(pageParams);
    }

    @WebLog(type = ApiType.READ)
    @Permission(type = PermissionType.TENANT)
    @GetMapping("queryOne")
    public TenantUser queryOne(Integer id) {
        return this.facade.queryOne(id);
    }

    @WebLog(type = ApiType.SAVE_OR_UPDATE)
    @Permission(type = PermissionType.TENANT)
    @PostMapping("saveOrUpdate")
    public TenantUser saveOrUpdate(@RequestBody TenantUser entity) {
        return this.facade.saveOrUpdate(entity);
    }
}
